package top.korori.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.korori.common.model.PageData;
import top.korori.common.model.Result;
import top.korori.system.annotation.PreAuth;
import top.korori.system.entity.bo.SysLoginLogBo;
import top.korori.system.service.SysLoginLogService;
import top.korori.system.entity.vo.SysLoginLogVo;

import java.util.List;

/**
 * 
 * 登录日志 前端控制器
 * 
 *
 * @author korori
 * @since
 */
@Api(tags = "登录日志")
@RestController
@RequestMapping("/sys/loginlog")
public class SysLoginLogController {

    @Autowired
    private SysLoginLogService sysLoginLogService;

    @ApiOperation("获取登录日志列表")
    @PreAuth("sys:loginlog:list")
    @GetMapping("/list")
    public Result<PageData<SysLoginLogVo>> list(SysLoginLogBo sysLoginLogBo){
        PageData<SysLoginLogVo> sysLoginLogVoPageData = sysLoginLogService.list(sysLoginLogBo);
        return Result.ok(sysLoginLogVoPageData);
    }

    @ApiOperation("获取日志信息")
    @PreAuth("sys:loginlog:query")
    @GetMapping("/get/{loginLogId}")
    public Result<SysLoginLogVo> get(@PathVariable Long loginLogId){
        SysLoginLogVo sysLoginLogVo = sysLoginLogService.get(loginLogId);
        return Result.ok(sysLoginLogVo);
    }

    @ApiOperation("删除登录日志")
    @PreAuth("sys:loginlog:del")
    @DeleteMapping("/del/{loginLogIds}")
    public Result<Void> del(@PathVariable List<Long> loginLogIds){
        sysLoginLogService.removeByIds(loginLogIds);
        return Result.ok();
    }

}












